package ar.edu.unsam.algo3.plantasvszombies.dominio

import ar.edu.unsam.algo3.plantasvszombies.dominio.SerVivo
import java.util.Random
import org.uqbar.commons.utils.Observable

@Observable
class Zombie extends SerVivo implements Cloneable{

	override Zombie clone() {
		super.clone as Zombie
	}
	
	def boolean daPremio() {
		new Random().nextInt(2) >= 0.5
	}

	def boolean ganaPlanta() {
		if(new Random().nextInt(2) > 0.5) return true
		return false
	}
	
	override morir(Fila fila) {
		if(this.daPremio){
			if(this.ganaPlanta){
				fila.jardinZen.lugares = fila.jardinZen.lugares + 1
			}
			else
				fila.jardin.recursos = fila.jardin.recursos + 200
		}
	}

}
